﻿@using OBUCare.Web.Models;
@using OBUCare.Core.BL;
@using OBUCare.Core.Models;
@using OBUCare.Core.DataAccess;
@model RepairDetailsViewModel
@{
    Layout = "";
    ViewBag.Title = "标签维修单详情";
    decimal repairFeeSum = 0;
    string backDate = "该标签还未返厂";
    int infocustomerDate = 0;
    decimal serviceFee = 0;
}
<h2>
    <font color="#4fb82c" class="txt14_24">标签维修单详情&gt;&gt;</font>
</h2>
<div>
    @{

        var returnUrl = ViewContext.HttpContext.Request.UrlReferrer;
    }
    <input type="button" value="关闭" id="returnUrl" onclick="CloseWindow()" />
</div>
<div>
    <br />
    <img src="@Url.Content("~/Content/images/blueline1.png")" width="100%" height="21">
    <br />
</div>
<div style="text-align: center">
    <table width="100%">
        <tr>
            <td align="center">
                <span style="font-size: 14px; font-weight: bold">标签维修进度跟踪</span>
            </td>
        </tr>
        <tr>
            <td>
                <img src="@Url.Content("~/Content/images/blueline1.png")" width="100%" height="21">
            </td>
        </tr>
        <tr>
            <td align="center">
                <table width="100%">
                    @if (Model.OrderTracking != null)
                    {
                        if (Model.OrderTracking.Count() > 0)
                        {
                            foreach (var item in Model.OrderTracking)
                            {
                                //if (item.REPAIR_ORDER_Status == Convert.ToInt16(RepairOrderStatus.ReturnedToSupplier))
                                //{
                                //    //backDate = item.CREATED_DATE.ToShortDateString() == null ? "该标签还未返厂" : item.CREATED_DATE.ToShortDateString();
                                //}

                                <tr>
                                    <td style="width: 10%; text-align: right">
                                        时间：
                                    </td>
                                    <td style="width: 20%; text-align: left">
                                        @item.CREATED_DATE
                                    </td>
                                    <td style="width: 10%; text-align: right">
                                        操作员：
                                    </td>
                                    <td style="width: 15%; text-align: left">
                                        @{
                                IEnumerable<OPERATOR> olist = new ISSUE_RPTContext().GetOPERATORS();
                                OPERATOR o = (from i in olist where i.OPERATOR_NO == item.Operator_NO select i).FirstOrDefault();
                                        }
                                        @o.OPERATOR_NAME
                                    </td>
                                    <td style="width: 10%; text-align: right">
                                        说明：
                                    </td>
                                    <td style="width: 35%; text-align: left">
                                        @item.REMARK
                                    </td>
                                </tr>
                            }
                        }
                        else
                        {
                            <tr>
                                <td>
                                    暂无进度跟踪信息
                                </td>
                            </tr>
                        }
                    }
                    else
                    {
                        <tr>
                            <td>
                                暂无进度跟踪信息
                            </td>
                        </tr>
                    }
                </table>
            </td>
        </tr>
        <tr>
            <td>
                <img src="@Url.Content("~/Content/images/blueline1.png")" width="100%" height="21">
            </td>
        </tr>
        <tr>
            <td align="center">
                <span style="font-size: 14px; font-weight: bold">标签维修详细信息</span>
            </td>
        </tr>
        <tr>
            <td>
                <img src="@Url.Content("~/Content/images/blueline1.png")" width="100%" height="21">
            </td>
        </tr>
        <tr>
            <td align="center">
                <table width="100%">
                    @if ((Model.ObuInfo != null) && (Model.ObuInfo.RepairOrder != null))
                    {
                        ConfigMgr c = new ConfigMgr(); DICT_TYPE_VALUE facestatus = c.GetTypeValue("0", Convert.ToInt16(@Model.ObuInfo.RepairOrder.FACE_STATUS).ToString());
                        OBUCareOrderMgr obuMgr = new OBUCareOrderMgr();
                        REPAIR_TYPE repairType = obuMgr.getRepairTypeValueBy(@Model.ObuInfo.RepairOrder.REPAIR_TYPE);
                        <tr>
                            <td style="width: 15%; text-align: right">
                                维修单号：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @Model.ObuInfo.RepairOrder.REPAIR_ORDER_NO
                            </td>
                            <td style="width: 15%; text-align: right">
                                受理日期：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @Model.ObuInfo.RepairOrder.REPORT_DATE.ToShortDateString()
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 15%; text-align: right">
                                标签号：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @Model.ObuInfo.RepairOrder.OBU_NO
                            </td>
                            <td style="width: 15%; text-align: right">
                                @if (!ViewBag.IsOneRepair)
                                {
                                    <label>维修性质：</label>
                                }

                            </td>
                            <td style="width: 35%; text-align: left">
                                @if (!ViewBag.IsOneRepair)
                                {
                                    @repairType.TITLE
                                }
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 15%; text-align: right">
                                厂商：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @Model.ObuInfo.RepairOrder.SUPPLIER_ShortName
                            </td>
                            <td style="width: 15%; text-align: right">
                                型号：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @Model.ObuInfo.RepairOrder.SPEC_NAME
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 15%; text-align: right">
                                客户编号：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @Model.ObuInfo.RepairOrder.USER_NO
                            </td>
                            <td style="width: 15%; text-align: right">
                                所有人：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @Model.ObuInfo.RepairOrder.OWNER_NAME
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 15%; text-align: right">
                                车牌号：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @Model.ObuInfo.RepairOrder.VEHICLE_PLATE_NO
                            </td>
                            <td style="width: 15%; text-align: right">
                                车型：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @Model.ObuInfo.RepairOrder.VEHICLE_CLASS_NAME
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 15%; text-align: right">
                                接收短信手机：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @{Model.ObuInfo.RepairOrder.MOBILE_TEL_NO = Model.ObuInfo.RepairOrder.MOBILE_TEL_NO == null ? "无" : Model.ObuInfo.RepairOrder.MOBILE_TEL_NO;}
                                @Model.ObuInfo.RepairOrder.MOBILE_TEL_NO
                            </td>
                            <td style="width: 15%; text-align: right">
                                固定电话：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @{Model.ObuInfo.RepairOrder.TEL_NO = Model.ObuInfo.RepairOrder.TEL_NO == null ? "无" : Model.ObuInfo.RepairOrder.TEL_NO;}
                                @Model.ObuInfo.RepairOrder.TEL_NO
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 15%; text-align: right">
                                接受维修费用：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @Model.ObuInfo.RepairOrder.MAX_PRICE
                            </td>
                            <td style="width: 15%; text-align: right">
                                送修人：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @Model.ObuInfo.RepairOrder.REPORTER
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 15%; text-align: right">
                                故障描述：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @Model.RepairFaultRemark
                            </td>
                            <td style="width: 15%; text-align: right">
                                外观检测：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @facestatus.DICT_TITLE
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 15%; text-align: right">
                                备用标签号：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @{string spareObuNo = Model.ObuInfo.RepairOrder.SPARE_OBU_NO == null ? "无备签" : Model.ObuInfo.RepairOrder.SPARE_OBU_NO;}
                                @spareObuNo
                            </td>
                            <td style="width: 15%; text-align: right">
                                押金：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @{decimal? spareObuPrice = Model.ObuInfo.RepairOrder.SPARE_OBU_PRICE == null ? 0 : Model.ObuInfo.RepairOrder.SPARE_OBU_PRICE;}
                                @spareObuPrice<span>(元)<span>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 15%; text-align: right">
                                备签安装日期：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @{string issueDate = Model.ObuInfo.RepairOrder.SPARE_OBU_ISSUE_DATE == null ? "无" : Convert.ToDateTime(Model.ObuInfo.RepairOrder.SPARE_OBU_ISSUE_DATE).ToShortDateString();}
                                @issueDate
                            </td>
                            <td style="width: 15%; text-align: right">
                                维修类型：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @if (ViewBag.IsOneRepair)
                                {
                                    <label>一口价维修（维修费用：@ViewBag.OnePay）</label>
                                }
                                else
                                {
                                    <label>普通维修</label>
                                }
                            </td>
                        </tr>
                    }
                    else
                    {
                        <tr>
                            <td>
                                暂无该维修单信息
                            </td>
                        </tr>
                    }
                </table>
            </td>
        </tr>
        <tr>
            <td>
                <img src="@Url.Content("~/Content/images/blueline1.png")" width="100%" height="21">
            </td>
        </tr>
        <tr>
            <td align="center">
                <span style="font-size: 14px; font-weight: bold">厂商报价信息</span>
            </td>
        </tr>
        <tr>
            <td>
                <img src="@Url.Content("~/Content/images/blueline1.png")" width="100%" height="21">
            </td>
        </tr>
        <tr>
            <td align="center">
                <table width="100%">
                    @if ((Model.ObuInfo != null) && (Model.ObuInfo.RepairOrder != null))
                    {
                        backDate = Model.BackDate == null ? "该标签无报价信息" : Convert.ToDateTime(Model.BackDate).ToShortDateString();
                        <tr>
                            <td style="width: 15%; text-align: right">
                                厂商：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @Model.ObuInfo.RepairOrder.SUPPLIER
                            </td>
                            <td style="width: 15%; text-align: right">
                                报价日期：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @backDate
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right">
                                厂商处理意见：
                            </td>
                            <td style="text-align: left" colspan="3">
                                @Model.ObuInfo.RepairOrder.DISPOSE_TYPE_Title (注：无报价信息时，默认为维修)
                            </td>
                        </tr>
                    }
                    @if (Model.ObuInfo.RepairFeeModel.Count() > 0)
                    {
                        foreach (var item in Model.ObuInfo.RepairFeeModel)
                        {
                            repairFeeSum = repairFeeSum + item.RepairPrice.PRICE;
                            <tr>
                                <td style="width: 15%; text-align: right">
                                    故障点：
                                </td>
                                <td style="width: 35%; text-align: left">
                                    @item.PartsType.PARTS_NAME
                                </td>
                                <td style="width: 15%; text-align: right">
                                    金额：
                                </td>
                                <td style="width: 35%; text-align: left">
                                    @item.RepairPrice.PRICE<span>(元) </span>
                                </td>
                            </tr>
                        }
                    }
                    else
                    {
                        <tr>
                            <td style="width: 15%; text-align: right">
                                故障点：
                            </td>
                            <td style="width: 35%; text-align: left">
                                无
                            </td>
                            <td style="width: 15%; text-align: right">
                                金额：
                            </td>
                            <td style="width: 35%; text-align: left">
                                0(元)
                            </td>
                        </tr>
                    }
                    <tr>
                        <td colspan="2"></td>
                        <td style="text-align: right">
                            维修费合计：
                        </td>
                        <td style="text-align: left">
                            @repairFeeSum
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
                <img src="@Url.Content("~/Content/images/blueline1.png")" width="100%" height="21">
            </td>
        </tr>
        <tr>
            <td>
                <span style="font-size: 14px; font-weight: bold">维修费调整信息</span>
            </td>
        </tr>
        <tr>
            <td>
                <img src="@Url.Content("~/Content/images/blueline1.png")" width="100%" height="21">
            </td>
        </tr>
        <tr>
            <td align="center">
                <table width="100%">
                    @if (Model.ObuInfo.RepairFeeAdjust != null && Model.ObuInfo.RepairFeeAdjust.Count() > 0)
                    {
                        foreach (var item in Model.ObuInfo.RepairFeeAdjust)
                        {
                            repairFeeSum = repairFeeSum + item.AMOUNT;
                            <tr>
                                <td style="width: 15%; text-align: right">
                                    调整金额：
                                </td>
                                <td style="width: 35%; text-align: left">
                                    @item.AMOUNT (元)
                                </td>
                                <td style="width: 15%; text-align: right">
                                    调整原因：
                                </td>
                                <td style="width: 35%; text-align: left">
                                    @item.COMMENT
                                </td>
                            </tr>
                        }
                    }
                    else
                    {
                        <tr>
                            <td style="width: 15%; text-align: right">
                                调整金额：
                            </td>
                            <td style="width: 35%; text-align: left">
                                0 (元)
                            </td>
                            <td style="width: 15%; text-align: right">
                                调整原因：
                            </td>
                            <td style="width: 35%; text-align: left">
                                无
                            </td>
                        </tr>
                    }
                    <tr>
                        <td colspan="2"></td>
                        <td style="text-align: right">
                            维修费共计：
                        </td>
                        <td style="text-align: left">
                            @repairFeeSum
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
                <img src="@Url.Content("~/Content/images/blueline1.png")" width="100%" height="21">
            </td>
        </tr>
        <tr>
            <td>
                <span style="font-size: 14px; font-weight: bold">服务费信息</span>
            </td>
        </tr>
        <tr>
            <td>
                <img src="@Url.Content("~/Content/images/blueline1.png")" width="100%" height="21">
            </td>
        </tr>
        <tr>
            <td align="center">
                <table width="100%">
                    @if (Model != null && Model.ObuInfo.RepairOrder != null)
                    {
                        <tr>
                            <td style="width: 15%; text-align: right">
                                逾期天数：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @{ if (Model.ObuInfo.RepairOrder.SPARE_OBU_ISSUE_DATE == null && Model.ObuInfo.RepairOrder.SPARE_OBU_PRICE == null
                                       && Model.ObuInfo.RepairOrder.SPARE_OBU_NO == null) //如果没有备签 则不计算服务费
                                 {
                                     infocustomerDate = 0;
                                 }
                                 else
                                 {
                                     IEnumerable<REPAIR_ORDER_TRACKING> repair_Tracking = Model.OrderTracking.ToList();
                                     REPAIR_ORDER_TRACKING findT = (from i in repair_Tracking
                                                                    where i.REPAIR_ORDER_Status == Convert.ToInt32(RepairOrderStatus.InformedCustomer)
                                                                    select i).FirstOrDefault();
                                     infocustomerDate = findT == null || findT.CREATED_DATE == null ? 0 :
                                         (DateTime.Now - findT.CREATED_DATE.AddDays(Convert.ToInt32(ServiceFeeCheck.ServiceFeeDay))).Days < 0 ? 0 :
                                         (DateTime.Now - findT.CREATED_DATE.AddDays(Convert.ToInt32(ServiceFeeCheck.ServiceFeeDay))).Days;
                                 }

                                }
                                @infocustomerDate<span>(天)</span>
                            </td>
                            <td style="width: 15%; text-align: right">
                                服务费单价：
                            </td>
                            <td style="width: 35%; text-align: left">
                                @Convert.ToInt32(ServiceFeeCheck.ServiceFeePrice)<span>(元)/天</span>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2"></td>
                            <td style="text-align: right">
                                服务费共计：
                            </td>
                            <td style="text-align: left">
                                @{serviceFee = Convert.ToInt32(infocustomerDate * Convert.ToInt32(ServiceFeeCheck.ServiceFeePrice));
                                serviceFee = serviceFee > 300 ? 300 : serviceFee;
                                }
                                @(serviceFee) <span>(元)</span>
                            </td>
                        </tr>
                    }
                </table>
            </td>
        </tr>
        <tr>
            <td>
                <img src="@Url.Content("~/Content/images/blueline1.png")" width="100%" height="21">
            </td>
        </tr>
        <tr>
            <td>
                <span style="font-size: 14px; font-weight: bold">服务费调整信息</span>
            </td>
        </tr>
        <tr>
            <td>
                <img src="@Url.Content("~/Content/images/blueline1.png")" width="100%" height="21">
            </td>
        </tr>
        <tr>
            <td align="center">
                <table width="100%">
                    @if (Model.ObuInfo != null && Model.ObuInfo.ServiceFeeAdjust.Count() > 0)
                    {
                        foreach (var item in Model.ObuInfo.ServiceFeeAdjust)
                        {
                            serviceFee = serviceFee + item.AMOUNT;
                            <tr>
                                <td style="width: 15%; text-align: right">
                                    调整金额：
                                </td>
                                <td style="width: 35%; text-align: left">
                                    @item.AMOUNT (元)
                                </td>
                                <td style="width: 15%; text-align: right">
                                    调整原因：
                                </td>
                                <td style="width: 35%; text-align: left">
                                    @item.COMMENT
                                </td>
                            </tr>
                        }
                    }
                    else
                    {
                        <tr>
                            <td style="width: 15%; text-align: right">
                                调整金额：
                            </td>
                            <td style="width: 35%; text-align: left">
                                0 (元)
                            </td>
                            <td style="width: 15%; text-align: right">
                                调整原因：
                            </td>
                            <td style="width: 35%; text-align: left">
                                无
                            </td>
                        </tr>
                    }
                    <tr>
                        <td colspan="2"></td>
                        <td style="text-align: right">
                            服务费共计：
                        </td>
                        <td style="text-align: left">
                            @serviceFee (元)
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
                <img src="@Url.Content("~/Content/images/blueline1.png")" width="100%" height="21">
            </td>
        </tr>
    </table>
</div>
<div>
    <p>
        <input type="button" onclick="window.open('/RepairOrders/Print/@Model.ObuInfo.RepairOrder.ID')" value="打印" />
    </p>
</div>
<script src="@Url.Content("~/Scripts/jquery-1.7.1.js")" type="text/javascript"></script>
<script type="text/javascript">
    //新添加“返回”按钮的点击事件
    $(function () {
        $("#returnUrl").click(function () {
            location.href = "@returnUrl";
        })
    })
</script>
